#include <stdio.h>

struct Staff {
    char name[15];
    float base;
    float bonus;
    float cost;
};

int main() {
    int n;
    scanf("%d", &n);
    struct Staff s[10000];
    for (int i = 0; i < n; i++) {
        scanf("%s %f %f %f", s[i].name, &s[i].base, &s[i].bonus, &s[i].cost);
    }
    for (int i = 0; i < n; i++) {
        float real = s[i].base + s[i].bonus - s[i].cost;
        printf("%s %.2f\n", s[i].name, real);
    }
    return 0;
}
